version: '3'
 
services:
    php:
        build:
            context: ./config/php
        ports:
            - 9000:9000
        volumes:
            - ./web:/srv/www/api
            - ./config/php/www.conf:/usr/local/etc/php-fpm.d/www.conf
        environment:
            MYSQL_USER: ${DB_USER}
            MYSQL_PASSWORD: ${DB_PASSWORD}
        depends_on:
            - db
        links:
            - db
 
    nginx:
        image: nginx:1.17
        ports:
            - 80:80
        volumes:
            - ./web:/srv/www/api
            - ./config/nginx/default.conf:/etc/nginx/conf.d/default.conf
        depends_on:
            - php
 
    pma:
        image: phpmyadmin/phpmyadmin
        environment:
            PMA_HOST: db
            PMA_PORT: 3306
            MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"
        ports:
            - ${IP}:8000:80
        links:
            - db:db

    db:
        image: mysql:latest
        ports:
            - ${IP}:3300:3306
        command: "mysqld --init-file /data/application/init.sql"
        volumes:
            - ./data/init.sql:/data/application/init.sql
            - db_data:/var/lib/mysql
        environment:
            MYSQL_DATABASE: "${DB_NAME}"
            MYSQL_ROOT_PASSWORD: "${DB_PASSWORD}"

volumes:
    db_data:
